package com.graph;

import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;

public class Solution997 {
    public int findJudge(int n, int[][] trust) {
        int[] in = new int[n + 1];
        int[] out = new int[n + 1];
        for (int[] ints : trust) {
            out[ints[0]]++;
            in[ints[1]]++;
        }
        for (int i = 1; i <= n; i++) {
            if (out[i] == 0 && in[i] == n - 1) return i;
        }
        return -1;
    }
}
